package com.zsj.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zsj.controller.base.BaseController;

/**
 * Hello World Demo
 * 
 * @author Zsj
 */
//@RestController注解:其实就是@Controller和@ResponseBody注解加在一起
@Controller
@RequestMapping(value = "/welcome")
public class WelcomeController extends BaseController {
	
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
    
	/**
	 * 测试要点：使用Spring Boot提供的默认配置的模板引擎：Thymeleaf、FreeMarker、Velocity，来渲染Web视图
	 */
	@RequestMapping("/thymeleaf")
	public String thymeleaf() {
        System.out.println("@@@thymeleaf!!!");
		return "welcome/index";
	}
	
	/**
	 * 测试要点：要使用JSP渲染Web视图，必须要在pom.xml中去掉Spring Boot提供的默认配置的模板引擎：Thymeleaf、 FreeMarker、 Velocity 的依赖配置才行，否则就按pom.xml里引入的模板优先来渲染Web页面
	 *//*
	@RequestMapping("/jsp")
	public String jsp() {
		System.out.println("@@@jsp!!!");
	    return "welcome/hello";
	}*/
	
	@ResponseBody
	@RequestMapping("/helloworld")
	public String helloworld() {
		System.out.println("Hello springboot!");
		redisTemplate.opsForValue().set("hello_world", "Hello World!!");
		return "Hello springboot!";
	}
}
